package com.sicheng.algorithm.math;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/1/23 16:18
 */
public class 计算1ToN {
    public static void main(String[] args) {
        // (1+ n )*n  / 2
        int n = 10;

        System.out.println(sum(n));
    }

    public static int sum(int n) {
        int sum = n;
        boolean stop = (n > 0) && ((sum += sum(n - 1)) > 0);
        return sum;
    }
}
